public interface LDClientInterface
extends java.io.Closeable
To obtain a client instance, use LDClient
methods such as LDClient.init(Application, LDConfig, LDUser)
.
Modifier and Type | Method and Description |
---|---|
java.util.Map<java.lang.String,LDValue> |
allFlags()
Returns a map of all feature flags for the current user.
|
boolean |
boolVariation(java.lang.String flagKey,
boolean defaultValue)
Returns the flag value for the current user.
|
EvaluationDetail<java.lang.Boolean> |
boolVariationDetail(java.lang.String flagKey,
boolean defaultValue)
Returns the flag value for the current user, along with information about how it was calculated.
|
double |
doubleVariation(java.lang.String flagKey,
double defaultValue)
Returns the flag value for the current user.
|
EvaluationDetail<java.lang.Double> |
doubleVariationDetail(java.lang.String flagKey,
double defaultValue)
Returns the flag value for the current user, along with information about how it was calculated.
|
void |
flush()
Sends all pending events to LaunchDarkly.
|
ConnectionInformation |
getConnectionInformation()
Gets a
ConnectionInformation object from the client representing the current state
of the clients connection. |
java.lang.String |
getVersion()
Returns the version of the SDK, for instance "2.7.0".
|
java.util.concurrent.Future<java.lang.Void> |
identify(LDUser user)
Sets the current user, retrieves flags for that user, then sends an Identify Event to LaunchDarkly.
|
int |
intVariation(java.lang.String flagKey,
int defaultValue)
Returns the flag value for the current user.
|
EvaluationDetail<java.lang.Integer> |
intVariationDetail(java.lang.String flagKey,
int defaultValue)
Returns the flag value for the current user, along with information about how it was calculated.
|
boolean |
isDisableBackgroundPolling()
Checks whether
LDConfig.Builder.disableBackgroundUpdating(boolean) was set to
true in the configuration. |
boolean |
isInitialized()
Checks whether the client is ready to return feature flag values.
|
boolean |
isOffline()
Checks whether the client has been put into offline mode.
|
LDValue |
jsonValueVariation(java.lang.String flagKey,
LDValue defaultValue)
Returns the flag value for the current user.
|
EvaluationDetail<LDValue> |
jsonValueVariationDetail(java.lang.String flagKey,
LDValue defaultValue)
Returns the flag value for the current user, along with information about how it was calculated.
|
void |
registerAllFlagsListener(LDAllFlagsListener allFlagsListener)
Registers a
LDAllFlagsListener to be called when a flag update is processed by the
SDK. |
void |
registerFeatureFlagListener(java.lang.String flagKey,
FeatureFlagChangeListener listener)
Registers a
FeatureFlagChangeListener to be called when the flagKey changes
from its current value. |
void |
registerStatusListener(LDStatusListener LDStatusListener)
Registers a
LDStatusListener to be called on connection status updates. |
void |
setOffline()
Shuts down any network connections maintained by the client and puts the client in offline
mode, preventing the client from opening new network connections until
setOnline() is called. |
void |
setOnline()
Restores network connectivity for the client, if the client was previously in offline mode.
|
java.lang.String |
stringVariation(java.lang.String flagKey,
java.lang.String defaultValue)
Returns the flag value for the current user.
|
EvaluationDetail<java.lang.String> |
stringVariationDetail(java.lang.String flagKey,
java.lang.String defaultValue)
Returns the flag value for the current user, along with information about how it was calculated.
|
void |
track(java.lang.String eventName)
Tracks that a user performed an event.
|
void |
trackData(java.lang.String eventName,
LDValue data)
Tracks that a user performed an event, and provides additional custom data.
|
void |
trackMetric(java.lang.String eventName,
LDValue data,
double metricValue)
Tracks that a user performed an event, and provides an additional numeric value for custom metrics.
|
void |
unregisterAllFlagsListener(LDAllFlagsListener allFlagsListener)
Unregisters a
LDAllFlagsListener so it will no longer be called on flag updates. |
void |
unregisterFeatureFlagListener(java.lang.String flagKey,
FeatureFlagChangeListener listener)
Unregisters a
FeatureFlagChangeListener for the flagKey . |
void |
unregisterStatusListener(LDStatusListener LDStatusListener)
Unregisters a
LDStatusListener so it will no longer be called on connection status updates. |
boolean isInitialized()
boolean isOffline()
setOffline()
was called, or if the configuration had LDConfig.Builder.offline(boolean)
set to true,
not if the client is simply offline due to a loss of network connectivity.void setOffline()
setOnline()
is called.
Note: The client automatically monitors the device's network connectivity and app foreground
status, so calling setOffline()
or setOnline()
is normally
unnecessary in most situations.
void setOnline()
Note: The client automatically monitors the device's network connectivity and app foreground
status, so calling setOffline()
or setOnline()
is normally
unnecessary in most situations.
void trackMetric(java.lang.String eventName, LDValue data, double metricValue)
eventName
- the name of the eventdata
- an LDValue
containing additional data associated with the event; if not applicable,
you may pass either null
or LDValue.ofNull()
metricValue
- A numeric value used by the LaunchDarkly experimentation feature in
numeric custom metrics. This field will also be returned as part of the
custom event for Data Export.void trackData(java.lang.String eventName, LDValue data)
eventName
- the name of the eventdata
- an LDValue
containing additional data associated with the eventvoid track(java.lang.String eventName)
eventName
- the name of the eventjava.util.concurrent.Future<java.lang.Void> identify(LDUser user)
user
- The user for evaluation and event reportingvoid flush()
java.util.Map<java.lang.String,LDValue> allFlags()
boolean boolVariation(java.lang.String flagKey, boolean defaultValue)
defaultValue
when one of the following occurs:
flagKey
- key for the flag to evaluatedefaultValue
- default value in case of errors evaluating the flagEvaluationDetail<java.lang.Boolean> boolVariationDetail(java.lang.String flagKey, boolean defaultValue)
evaluationReasons
to true with
LDConfig.Builder.evaluationReasons(boolean)
. Otherwise, the reason
property of the result
will be null.flagKey
- key for the flag to evaluatedefaultValue
- default value in case of errors evaluating the flag (see boolVariation(String, boolean)
)EvaluationDetail
object containing the value and other information.int intVariation(java.lang.String flagKey, int defaultValue)
defaultValue
when one of the following occurs:
flagKey
- key for the flag to evaluatedefaultValue
- default value in case of errors evaluating the flagEvaluationDetail<java.lang.Integer> intVariationDetail(java.lang.String flagKey, int defaultValue)
evaluationReasons
to true with
LDConfig.Builder.evaluationReasons(boolean)
. Otherwise, the reason
property of the result
will be null.flagKey
- key for the flag to evaluatedefaultValue
- default value in case of errors evaluating the flag (see intVariation(String, int)
)EvaluationDetail
object containing the value and other information.double doubleVariation(java.lang.String flagKey, double defaultValue)
defaultValue
when one of the following occurs:
flagKey
- key for the flag to evaluatedefaultValue
- default value in case of errors evaluating the flagEvaluationDetail<java.lang.Double> doubleVariationDetail(java.lang.String flagKey, double defaultValue)
evaluationReasons
to true with
LDConfig.Builder.evaluationReasons(boolean)
. Otherwise, the reason
property of the result
will be null.flagKey
- key for the flag to evaluatedefaultValue
- default value in case of errors evaluating the flag (see doubleVariation(String, double)
)EvaluationDetail
object containing the value and other information.java.lang.String stringVariation(java.lang.String flagKey, java.lang.String defaultValue)
default
when one of the following occurs:
flagKey
- key for the flag to evaluatedefaultValue
- default value in case of errors evaluating the flagEvaluationDetail<java.lang.String> stringVariationDetail(java.lang.String flagKey, java.lang.String defaultValue)
evaluationReasons
to true with
LDConfig.Builder.evaluationReasons(boolean)
. Otherwise, the reason
property of the result
will be null.flagKey
- key for the flag to evaluatedefaultValue
- default value in case of errors evaluating the flag (see stringVariation(String, String)
)EvaluationDetail
object containing the value and other information.void registerFeatureFlagListener(java.lang.String flagKey, FeatureFlagChangeListener listener)
FeatureFlagChangeListener
to be called when the flagKey
changes
from its current value. If the feature flag is deleted, the listener
will be unregistered.flagKey
- the flag key to attach the listener tolistener
- the listener to attach to the flag keyunregisterFeatureFlagListener(String, FeatureFlagChangeListener)
LDValue jsonValueVariation(java.lang.String flagKey, LDValue defaultValue)
defualtValue
when one of the following occurs:
flagKey
- key for the flag to evaluatedefaultValue
- default value in case of errors evaluating the flagEvaluationDetail<LDValue> jsonValueVariationDetail(java.lang.String flagKey, LDValue defaultValue)
evaluationReasons
to true with
LDConfig.Builder.evaluationReasons(boolean)
. Otherwise, the reason
property of the result
will be null.flagKey
- key for the flag to evaluatedefaultValue
- default value in case of errors evaluating the flag (see jsonValueVariation(String, LDValue)
)EvaluationDetail
object containing the value and other information.void unregisterFeatureFlagListener(java.lang.String flagKey, FeatureFlagChangeListener listener)
FeatureFlagChangeListener
for the flagKey
.flagKey
- the flag key to remove the listener fromlistener
- the listener to remove from the flag keyregisterFeatureFlagListener(String, FeatureFlagChangeListener)
ConnectionInformation getConnectionInformation()
ConnectionInformation
object from the client representing the current state
of the clients connection.void unregisterStatusListener(LDStatusListener LDStatusListener)
LDStatusListener
so it will no longer be called on connection status updates.LDStatusListener
- the listener to be removedvoid registerStatusListener(LDStatusListener LDStatusListener)
LDStatusListener
to be called on connection status updates.LDStatusListener
- the listener to be called on a connection status updatevoid registerAllFlagsListener(LDAllFlagsListener allFlagsListener)
LDAllFlagsListener
to be called when a flag update is processed by the
SDK.allFlagsListener
- the listener to be called with a list of flag keys on a flag updatevoid unregisterAllFlagsListener(LDAllFlagsListener allFlagsListener)
LDAllFlagsListener
so it will no longer be called on flag updates.allFlagsListener
- the listener to be removedboolean isDisableBackgroundPolling()
LDConfig.Builder.disableBackgroundUpdating(boolean)
was set to
true
in the configuration.java.lang.String getVersion()