public final class FeatureFlagsState extends java.lang.Object implements JsonSerializable
LDClientInterface.allFlagsState(com.launchdarkly.sdk.LDContext, 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:
JsonSerialization
.
Gson
instance with
LDGson
.
ObjectMapper
instance with
LDJackson
.
Modifier and Type | Class and Description |
---|---|
static class |
FeatureFlagsState.Builder
A builder for a
FeatureFlagsState instance. |
Modifier and Type | Method and Description |
---|---|
static FeatureFlagsState.Builder |
builder(FlagsStateOption... options)
Returns a
FeatureFlagsState.Builder for creating instances. |
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.
|
public static FeatureFlagsState.Builder builder(FlagsStateOption... options)
FeatureFlagsState.Builder
for creating instances.
Application code will not normally use this builder, since the SDK creates its own instances.
However, it may be useful in testing, to simulate values that might be returned by
LDClient.allFlagsState(com.launchdarkly.sdk.LDContext, FlagsStateOption...)
.
options
- the same FlagsStateOption
s, if any, that would be passed to
LDClient.allFlagsState(com.launchdarkly.sdk.LDContext, FlagsStateOption...)
public boolean isValid()
public LDValue getFlagValue(java.lang.String key)
key
- the feature flag keyLDValue.ofNull()
if the flag returned the default value;
null
if there was no such flagpublic EvaluationReason getFlagReason(java.lang.String key)
key
- the feature flag keyEvaluationReason
; null if reasons were not recorded, or if there was no such flagpublic java.util.Map<java.lang.String,LDValue> toValuesMap()
The returned map is unmodifiable.
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()
or Gson.toJsonTree()
.
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object