Package com.launchdarkly.sdk.server
Class FeatureFlagsState
java.lang.Object
com.launchdarkly.sdk.server.FeatureFlagsState
- All Implemented Interfaces:
JsonSerializable
public final class FeatureFlagsState extends java.lang.Object implements JsonSerializable
A snapshot of the state of all feature flags with regard to a specific user, generated by
calling
LDClientInterface.allFlagsState(com.launchdarkly.sdk.LDUser, FlagsStateOption...).
LaunchDarkly defines a standard JSON encoding for this object, suitable for bootstrapping the LaunchDarkly JavaScript browser SDK. You can convert it to JSON in any of these ways:
- With
JsonSerialization. - With Gson, if and only if you configure your
Gsoninstance withLDGson. - With Jackson, if and only if you configure your
ObjectMapperinstance withLDJackson.
- Since:
- 4.3.0
-
Method Summary
Modifier and Type Method Description booleanequals(java.lang.Object other)EvaluationReasongetFlagReason(java.lang.String key)Returns the evaluation reason for an individual feature flag at the time the state was recorded.LDValuegetFlagValue(java.lang.String key)Returns the value of an individual feature flag at the time the state was recorded.inthashCode()booleanisValid()Returns true if this object contains a valid snapshot of feature flag state, or false if the state could not be computed (for instance, because the client was offline or there was no user).java.util.Map<java.lang.String,LDValue>toValuesMap()Returns a map of flag keys to flag values.
-
Method Details
-
isValid
public boolean isValid()Returns true if this object contains a valid snapshot of feature flag state, or false if the state could not be computed (for instance, because the client was offline or there was no user).- Returns:
- true if the state is valid
-
getFlagValue
Returns the value of an individual feature flag at the time the state was recorded.- Parameters:
key- the feature flag key- Returns:
- the flag's JSON value;
LDValue.ofNull()if the flag returned the default value;nullif there was no such flag
-
getFlagReason
Returns the evaluation reason for an individual feature flag at the time the state was recorded.- Parameters:
key- the feature flag key- Returns:
- an
EvaluationReason; null if reasons were not recorded, or if there was no such flag
-
toValuesMap
Returns a map of flag keys to flag values. If a flag would have evaluated to the default value, its value will be null.Do not use this method if you are passing data to the front end to "bootstrap" the JavaScript client. Instead, serialize the FeatureFlagsState object to JSON using
Gson.toJson()orGson.toJsonTree().- Returns:
- an immutable map of flag keys to JSON values
-
equals
public boolean equals(java.lang.Object other)- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCodein classjava.lang.Object
-