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
Gson
instance withLDGson
. - With Jackson, if and only if you configure your
ObjectMapper
instance withLDJackson
.
- Since:
- 4.3.0
-
Method Summary
Modifier and Type Method Description boolean
equals(java.lang.Object other)
EvaluationReason
getFlagReason(java.lang.String key)
Returns the evaluation reason for an individual feature flag at the time the state was recorded.LDValue
getFlagValue(java.lang.String key)
Returns the value of an individual feature flag at the time the state was recorded.int
hashCode()
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).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;null
if 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:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCode
in classjava.lang.Object
-