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,?> |
allFlags()
Returns a map of all feature flags for the current user.
|
java.lang.Boolean |
boolVariation(java.lang.String flagKey,
java.lang.Boolean fallback)
Returns the flag value for the current user.
|
EvaluationDetail<java.lang.Boolean> |
boolVariationDetail(java.lang.String flagKey,
java.lang.Boolean fallback)
Returns the flag value for the current user, along with information about how it was calculated.
|
java.lang.Float |
floatVariation(java.lang.String flagKey,
java.lang.Float fallback)
Returns the flag value for the current user.
|
EvaluationDetail<java.lang.Float> |
floatVariationDetail(java.lang.String flagKey,
java.lang.Float fallback)
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.
|
java.lang.Integer |
intVariation(java.lang.String flagKey,
java.lang.Integer fallback)
Returns the flag value for the current user.
|
EvaluationDetail<java.lang.Integer> |
intVariationDetail(java.lang.String flagKey,
java.lang.Integer fallback)
Returns the flag value for the current user, along with information about how it was calculated.
|
boolean |
isDisableBackgroundPolling()
Checks whether
LDConfig.Builder.setDisableBackgroundUpdating(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.
|
com.google.gson.JsonElement |
jsonVariation(java.lang.String flagKey,
com.google.gson.JsonElement fallback)
Returns the flag value for the current user.
|
EvaluationDetail<com.google.gson.JsonElement> |
jsonVariationDetail(java.lang.String flagKey,
com.google.gson.JsonElement fallback)
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 fallback)
Returns the flag value for the current user.
|
EvaluationDetail<java.lang.String> |
stringVariationDetail(java.lang.String flagKey,
java.lang.String fallback)
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 |
track(java.lang.String eventName,
com.google.gson.JsonElement data)
Tracks that a user performed an event.
|
void |
track(java.lang.String eventName,
com.google.gson.JsonElement data,
java.lang.Double metricValue)
Tracks that a user performed an event.
|
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.setOffline(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 track(java.lang.String eventName, com.google.gson.JsonElement data, java.lang.Double metricValue)
eventName
- the name of the eventdata
- a JSON object containing additional data associated with the eventmetricValue
- A numeric value used by the LaunchDarkly experimentation feature in
numeric custom metrics. Can be omitted if this event is used by only
non-numeric metrics. This field will also be returned as part of the
custom event for Data Export.void track(java.lang.String eventName, com.google.gson.JsonElement data)
eventName
- the name of the eventdata
- a JSON object 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,?> allFlags()
java.lang.Boolean boolVariation(java.lang.String flagKey, java.lang.Boolean fallback)
fallback
when one of the following occurs:
flagKey
- key for the flag to evaluatefallback
- fallback value in case of errors evaluating the flagEvaluationDetail<java.lang.Boolean> boolVariationDetail(java.lang.String flagKey, java.lang.Boolean fallback)
evaluationReasons
to true with
LDConfig.Builder.setEvaluationReasons(boolean)
. Otherwise, the reason
property of the result
will be null.flagKey
- key for the flag to evaluatefallback
- fallback value in case of errors evaluating the flag (see boolVariation(String, Boolean)
)EvaluationDetail
object containing the value and other information.java.lang.Integer intVariation(java.lang.String flagKey, java.lang.Integer fallback)
fallback
when one of the following occurs:
flagKey
- key for the flag to evaluatefallback
- fallback value in case of errors evaluating the flagEvaluationDetail<java.lang.Integer> intVariationDetail(java.lang.String flagKey, java.lang.Integer fallback)
evaluationReasons
to true with
LDConfig.Builder.setEvaluationReasons(boolean)
. Otherwise, the reason
property of the result
will be null.flagKey
- key for the flag to evaluatefallback
- fallback value in case of errors evaluating the flag (see intVariation(String, Integer)
)EvaluationDetail
object containing the value and other information.java.lang.Float floatVariation(java.lang.String flagKey, java.lang.Float fallback)
fallback
when one of the following occurs:
flagKey
- key for the flag to evaluatefallback
- fallback value in case of errors evaluating the flagEvaluationDetail<java.lang.Float> floatVariationDetail(java.lang.String flagKey, java.lang.Float fallback)
evaluationReasons
to true with
LDConfig.Builder.setEvaluationReasons(boolean)
. Otherwise, the reason
property of the result
will be null.flagKey
- key for the flag to evaluatefallback
- fallback value in case of errors evaluating the flag (see floatVariation(String, Float)
)EvaluationDetail
object containing the value and other information.java.lang.String stringVariation(java.lang.String flagKey, java.lang.String fallback)
fallback
when one of the following occurs:
flagKey
- key for the flag to evaluatefallback
- fallback value in case of errors evaluating the flagEvaluationDetail<java.lang.String> stringVariationDetail(java.lang.String flagKey, java.lang.String fallback)
evaluationReasons
to true with
LDConfig.Builder.setEvaluationReasons(boolean)
. Otherwise, the reason
property of the result
will be null.flagKey
- key for the flag to evaluatefallback
- fallback value in case of errors evaluating the flag (see stringVariation(String, String)
)EvaluationDetail
object containing the value and other information.com.google.gson.JsonElement jsonVariation(java.lang.String flagKey, com.google.gson.JsonElement fallback)
fallback
when one of the following occurs:
flagKey
- key for the flag to evaluatefallback
- fallback value in case of errors evaluating the flagEvaluationDetail<com.google.gson.JsonElement> jsonVariationDetail(java.lang.String flagKey, com.google.gson.JsonElement fallback)
evaluationReasons
to true with
LDConfig.Builder.setEvaluationReasons(boolean)
. Otherwise, the reason
property of the result
will be null.flagKey
- key for the flag to evaluatefallback
- fallback value in case of errors evaluating the flag (see jsonVariation(String, JsonElement)
)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)
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 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.setDisableBackgroundUpdating(boolean)
was set to
true
in the configuration.java.lang.String getVersion()