Class FlagValueChangeEvent

java.lang.Object
com.launchdarkly.sdk.server.interfaces.FlagChangeEvent
com.launchdarkly.sdk.server.interfaces.FlagValueChangeEvent

public class FlagValueChangeEvent
extends FlagChangeEvent
Parameter class used with FlagValueChangeListener.

This is not an analytics event to be sent to LaunchDarkly; it is a notification to the application.

Since:
5.0.0
See Also:
FlagValueChangeListener, FlagTracker.addFlagValueChangeListener(String, com.launchdarkly.sdk.LDUser, FlagValueChangeListener)
  • Constructor Summary

    Constructors 
    Constructor Description
    FlagValueChangeEvent​(java.lang.String key, LDValue oldValue, LDValue newValue)
    Constructs a new instance.
  • Method Summary

    Modifier and Type Method Description
    LDValue getNewValue()
    Returns the new value of the flag for the specified user.
    LDValue getOldValue()
    Returns the last known value of the flag for the specified user prior to the update.

    Methods inherited from class com.launchdarkly.sdk.server.interfaces.FlagChangeEvent

    getKey

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • FlagValueChangeEvent

      public FlagValueChangeEvent​(java.lang.String key, LDValue oldValue, LDValue newValue)
      Constructs a new instance.
      Parameters:
      key - the feature flag key
      oldValue - the previous flag value
      newValue - the new flag value
  • Method Details

    • getOldValue

      public LDValue getOldValue()
      Returns the last known value of the flag for the specified user prior to the update.

      Since flag values can be of any JSON data type, this is represented as LDValue. That class has methods for converting to a primitive Java type such as LDValue.booleanValue().

      If the flag did not exist before or could not be evaluated, this will be LDValue.ofNull(). Note that there is no application default value parameter as there is for the variation methods; it is up to your code to substitute whatever fallback value is appropriate.

      Returns:
      the previous flag value
    • getNewValue

      public LDValue getNewValue()
      Returns the new value of the flag for the specified user.

      Since flag values can be of any JSON data type, this is represented as LDValue. That class has methods for converting to a primitive Java type such LDValue.booleanValue().

      If the flag was deleted or could not be evaluated, this will be LDValue.ofNull(). Note that there is no application default value parameter as there is for the variation methods; it is up to your code to substitute whatever fallback value is appropriate.

      Returns:
      the new flag value