Interface FBClient

All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
FBClientImp

public interface FBClient extends Closeable
This interface defines the public methods of FBClientImp.

Applications will normally interact directly with FBClientImp and must use its constructor to initialize the SDK.

  • Method Details

    • isInitialized

      boolean isInitialized()
      Tests whether the client is ready to be used.
      Returns:
      true if the client is ready, or false if it is still initializing
    • variation

      String variation(String featureFlagKey, FBUser user, String defaultValue)
      Calculates the value of a feature flag for a given user.

      Parameters:
      featureFlagKey - the unique key for the feature flag
      user - the end user requesting the flag
      defaultValue - the default value of the flag
      Returns:
      the variation for the given user, or defaultValue if the flag is disabled or an error occurs
    • boolVariation

      boolean boolVariation(String featureFlagKey, FBUser user, Boolean defaultValue)
      Calculates the boolean value of a feature flag for a given user.

      Parameters:
      featureFlagKey - the unique key for the feature flag
      user - the end user requesting the flag
      defaultValue - the default value of the flag
      Returns:
      if the flag should be enabled, or defaultValue if the flag is disabled or an error occurs
    • isEnabled

      boolean isEnabled(String featureFlagKey, FBUser user)
      alias of boolVariation for a given user
      Parameters:
      featureFlagKey - the unique key for the feature flag
      user - the end user requesting the flag
      Returns:
      if the flag should be enabled, or false if the flag is disabled, or an error occurs
    • doubleVariation

      double doubleVariation(String featureFlagKey, FBUser user, Double defaultValue)
      Calculates the double value of a feature flag for a given user.

      Parameters:
      featureFlagKey - the unique key for the feature flag
      user - the end user requesting the flag
      defaultValue - the default value of the flag
      Returns:
      the variation for the given user, or defaultValue if the flag is disabled or an error occurs
    • intVariation

      int intVariation(String featureFlagKey, FBUser user, Integer defaultValue)
      Calculates the integer value of a feature flag for a given user. Note that If the variation has a numeric value, but not an integer, it is rounded toward zero(DOWN mode)

      Parameters:
      featureFlagKey - the unique key for the feature flag
      user - the end user requesting the flag
      defaultValue - the default value of the flag
      Returns:
      the variation for the given user, or defaultValue if the flag is disabled or an error occurs
    • longVariation

      long longVariation(String featureFlagKey, FBUser user, Long defaultValue)
      Calculates the long value of a feature flag for a given user. Note that If the variation has a numeric value, but not a long value, it is rounded toward zero(DOWN mode)

      Parameters:
      featureFlagKey - the unique key for the feature flag
      user - the end user requesting the flag
      defaultValue - the default value of the flag
      Returns:
      the variation for the given user, or defaultValue if the flag is disabled or an error occurs
    • jsonVariation

      <T> T jsonVariation(String featureFlagKey, FBUser user, Class<T> clazz, T defaultValue)
      Calculates the json value of a feature flag for a given user.
      Type Parameters:
      T - json object type
      Parameters:
      featureFlagKey - the unique key for the feature flag
      user - the end user requesting the flag
      clazz - json deserialization class
      defaultValue - the default value of the flag
      Returns:
      the variation for the given user, or defaultValue if the flag is disabled, current user doesn't exist
    • isFlagKnown

      boolean isFlagKnown(String featureKey)
      Returns true if the specified feature flag currently exists.
      Parameters:
      featureKey - the unique key for the feature flag
      Returns:
      true if the flag exists
    • getDataUpdateStatusProvider

      Status.DataUpdateStatusProvider getDataUpdateStatusProvider()
      Returns an interface for tracking the status of the update processor.

      The update processor is the mechanism that the SDK uses to get feature flag, such as a streaming connection. The Status.DataUpdateStatusProvider is used to check whether the update processor is currently operational

      Returns:
      a Status.DataUpdateStatusProvider
    • initializeFromExternalJson

      boolean initializeFromExternalJson(String json)
      initialization in the offline mode

      Parameters:
      json - feature flags in the json format
      Returns:
      true if the initialization is well done
      Throws:
      JsonParseException - if json is invalid
    • getAllLatestFlagsVariations

      AllFlagStates<String> getAllLatestFlagsVariations(FBUser user)
      Returns a list of all feature flags value with details for a given user, including the reason that describes the way the value was determined, that can be used on the client side sdk or a front end .

      note that this method does not send insight events back to feature flag center.

      Parameters:
      user - the end user requesting the flag
      Returns:
      a AllFlagStates
    • variationDetail

      FlagState<String> variationDetail(String featureFlagKey, FBUser user, String defaultValue)
      Calculates the value of a feature flag for a given user, and returns an object that describes the way the value was determined.

      Parameters:
      featureFlagKey - the unique key for the feature flag
      user - the end user requesting the flag
      defaultValue - the default value of the flag
      Returns:
      an FlagState object
    • boolVariationDetail

      FlagState<Boolean> boolVariationDetail(String featureFlagKey, FBUser user, Boolean defaultValue)
      Calculates the value of a feature flag for a given user, and returns an object that describes the way the value was determined.

      Parameters:
      featureFlagKey - the unique key for the feature flag
      user - the end user requesting the flag
      defaultValue - the default value of the flag
      Returns:
      an FlagState object
    • doubleVariationDetail

      FlagState<Double> doubleVariationDetail(String featureFlagKey, FBUser user, Double defaultValue)
      Calculates the double value of a feature flag for a given user, and returns an object that describes the way the value was determined.

      Parameters:
      featureFlagKey - the unique key for the feature flag
      user - the end user requesting the flag
      defaultValue - the default value of the flag
      Returns:
      an FlagState object
    • intVariationDetail

      FlagState<Integer> intVariationDetail(String featureFlagKey, FBUser user, Integer defaultValue)
      Calculates the int value of a feature flag for a given user, and returns an object that describes the way the value was determined.

      Note that If the variation has a numeric value, but not an int value, it is rounded toward zero(DOWN mode)

      Parameters:
      featureFlagKey - the unique key for the feature flag
      user - the end user requesting the flag
      defaultValue - the default value of the flag
      Returns:
      an FlagState object
    • longVariationDetail

      FlagState<Long> longVariationDetail(String featureFlagKey, FBUser user, Long defaultValue)
      Calculates the long value of a feature flag for a given user, and returns an object that describes the way the value was determined.

      Note that If the variation has a numeric value, but not a long value, it is rounded toward zero(DOWN mode)

      Parameters:
      featureFlagKey - the unique key for the feature flag
      user - the end user requesting the flag
      defaultValue - the default value of the flag
      Returns:
      an FlagState object
    • jsonVariationDetail

      <T> FlagState<T> jsonVariationDetail(String featureFlagKey, FBUser user, Class<T> clazz, T defaultValue)
      Calculates the json value of a feature flag for a given user, and returns an object that describes the way the value was determined.
      Type Parameters:
      T - json object type
      Parameters:
      featureFlagKey - the unique key for the feature flag
      user - the end user requesting the flag
      clazz - json deserialization class
      defaultValue - the default value of the flag
      Returns:
      an FlagState object
    • flush

      void flush()
      Flushes all pending events.
    • identify

      void identify(FBUser user)
      register a user
      Parameters:
      user - user to register
    • trackMetric

      void trackMetric(FBUser user, String eventName)
      tracks that a user performed an event and provides a default numeric value for custom metrics
      Parameters:
      user - the user that performed the event
      eventName - the name of the event
    • trackMetric

      void trackMetric(FBUser user, String eventName, double metricValue)
      tracks that a user performed an event, and provides an additional numeric value for custom metrics.
      Parameters:
      user - the user that performed the event
      eventName - the name of the event
      metricValue - a numeric value used by the experimentation feature in numeric custom metrics.
    • trackMetrics

      void trackMetrics(FBUser user, String... eventNames)
      tracks that a user performed a series of events with default numeric value for custom metrics
      Parameters:
      user - the user that performed the event
      eventNames - event names
    • trackMetrics

      void trackMetrics(FBUser user, Map<String,Double> metrics)
      tracks that a user performed a series of events
      Parameters:
      user - the user that performed the event
      metrics - event name and numeric value in K/V