public final class EvaluationReason extends java.lang.Object implements JsonSerializable
This is returned within EvaluationDetail
by the SDK's "variation detail" methods such as
boolVariationDetail
.
Note that while EvaluationReason
has subclasses as an implementation detail, the subclasses
are not public and may be removed in the future. Always use methods of the base class such as
getKind()
or getRuleIndex()
to inspect the reason.
LaunchDarkly defines a standard JSON encoding for evaluation reasons, used in analytics events.
EvaluationReason
can be converted to and from JSON in any of these ways:
JsonSerialization
.
Gson
instance with
LDGson
.
ObjectMapper
instance with
LDJackson
.
Modifier and Type | Class and Description |
---|---|
static class |
EvaluationReason.BigSegmentsStatus
Enumerated type defining the possible values of
getBigSegmentsStatus() . |
static class |
EvaluationReason.ErrorKind
Enumerated type defining the possible values of
getErrorKind() . |
static class |
EvaluationReason.Kind
Enumerated type defining the possible values of
getKind() . |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object other) |
static EvaluationReason |
error(EvaluationReason.ErrorKind errorKind)
Returns an instance whose
kind is EvaluationReason.Kind.ERROR . |
static EvaluationReason |
exception(java.lang.Exception exception)
Returns an instance whose
kind is EvaluationReason.Kind.ERROR , with an exception instance. |
static EvaluationReason |
fallthrough()
Returns an instance whose
kind is EvaluationReason.Kind.FALLTHROUGH . |
static EvaluationReason |
fallthrough(boolean inExperiment)
Returns an instance whose
kind is EvaluationReason.Kind.FALLTHROUGH and
where the inExperiment parameter represents whether the evaluation was
part of an experiment. |
EvaluationReason.BigSegmentsStatus |
getBigSegmentsStatus()
Describes the validity of Big Segment information, if and only if the flag evaluation required
querying at least one Big Segment.
|
EvaluationReason.ErrorKind |
getErrorKind()
An enumeration value indicating the general category of error, if the
kind is EvaluationReason.Kind.PREREQUISITE_FAILED . |
java.lang.Exception |
getException()
The exception that caused the error condition, if the
kind is
EvaluationReason.Kind.ERROR and the errorKind is EvaluationReason.ErrorKind.EXCEPTION . |
EvaluationReason.Kind |
getKind()
Returns an enum indicating the general category of the reason.
|
java.lang.String |
getPrerequisiteKey()
The key of the prerequisite flag that did not return the desired variation, if the
kind is EvaluationReason.Kind.PREREQUISITE_FAILED . |
java.lang.String |
getRuleId()
The unique identifier of the rule that was matched, if the
kind is
EvaluationReason.Kind.RULE_MATCH . |
int |
getRuleIndex()
The index of the rule that was matched (0 for the first rule in the feature flag),
if the
kind is EvaluationReason.Kind.RULE_MATCH . |
int |
hashCode() |
boolean |
isInExperiment()
Whether the evaluation was part of an experiment.
|
static EvaluationReason |
off()
Returns an instance whose
kind is EvaluationReason.Kind.OFF . |
static EvaluationReason |
prerequisiteFailed(java.lang.String prerequisiteKey)
Returns an instance whose
kind is EvaluationReason.Kind.PREREQUISITE_FAILED . |
static EvaluationReason |
ruleMatch(int ruleIndex,
java.lang.String ruleId)
Returns an instance whose
kind is EvaluationReason.Kind.RULE_MATCH . |
static EvaluationReason |
ruleMatch(int ruleIndex,
java.lang.String ruleId,
boolean inExperiment)
Returns an instance whose
kind is EvaluationReason.Kind.RULE_MATCH and
where the inExperiment parameter represents whether the evaluation was
part of an experiment. |
static EvaluationReason |
targetMatch()
Returns an instance whose
kind is EvaluationReason.Kind.TARGET_MATCH . |
java.lang.String |
toString()
Returns a simple string representation of the reason.
|
EvaluationReason |
withBigSegmentsStatus(EvaluationReason.BigSegmentsStatus bigSegmentsStatus)
Returns a copy of this
EvaluationReason with a specific EvaluationReason.BigSegmentsStatus
value. |
public EvaluationReason.Kind getKind()
EvaluationReason.Kind
valuepublic int getRuleIndex()
kind
is EvaluationReason.Kind.RULE_MATCH
. Otherwise this returns -1.public java.lang.String getRuleId()
kind
is
EvaluationReason.Kind.RULE_MATCH
. Otherwise null
.
Unlike the rule index, this identifier will not change if other rules are added or deleted.
public java.lang.String getPrerequisiteKey()
kind
is EvaluationReason.Kind.PREREQUISITE_FAILED
. Otherwise null
.public boolean isInExperiment()
public EvaluationReason.ErrorKind getErrorKind()
kind
is EvaluationReason.Kind.PREREQUISITE_FAILED
. Otherwise null
.public java.lang.Exception getException()
kind
is
EvaluationReason.Kind.ERROR
and the errorKind
is EvaluationReason.ErrorKind.EXCEPTION
.
Otherwise null
.
Note that the exception will not be included in the JSON serialization of the reason when it appears in analytics events; it is only provided informationally for use by application code.
public EvaluationReason.BigSegmentsStatus getBigSegmentsStatus()
null
.
Big Segments are a specific type of user segments. For more information, read the LaunchDarkly documentation .
EvaluationReason.BigSegmentsStatus
from the evaluation or null
public EvaluationReason withBigSegmentsStatus(EvaluationReason.BigSegmentsStatus bigSegmentsStatus)
EvaluationReason
with a specific EvaluationReason.BigSegmentsStatus
value.bigSegmentsStatus
- the new property valuepublic java.lang.String toString()
This is a convenience method for debugging and any other use cases where a human-readable string is
helpful. The exact format of the string is subject to change; if you need to make programmatic
decisions based on the reason properties, use other methods like getKind()
.
toString
in class java.lang.Object
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public static EvaluationReason off()
kind
is EvaluationReason.Kind.OFF
.public static EvaluationReason fallthrough()
kind
is EvaluationReason.Kind.FALLTHROUGH
.public static EvaluationReason fallthrough(boolean inExperiment)
kind
is EvaluationReason.Kind.FALLTHROUGH
and
where the inExperiment parameter represents whether the evaluation was
part of an experiment.inExperiment
- whether the evaluation was part of an experimentpublic static EvaluationReason targetMatch()
kind
is EvaluationReason.Kind.TARGET_MATCH
.public static EvaluationReason ruleMatch(int ruleIndex, java.lang.String ruleId)
kind
is EvaluationReason.Kind.RULE_MATCH
.ruleIndex
- the rule indexruleId
- the rule identifierpublic static EvaluationReason ruleMatch(int ruleIndex, java.lang.String ruleId, boolean inExperiment)
kind
is EvaluationReason.Kind.RULE_MATCH
and
where the inExperiment parameter represents whether the evaluation was
part of an experiment.ruleIndex
- the rule indexruleId
- the rule identifierinExperiment
- whether the evaluation was part of an experimentpublic static EvaluationReason prerequisiteFailed(java.lang.String prerequisiteKey)
kind
is EvaluationReason.Kind.PREREQUISITE_FAILED
.prerequisiteKey
- the flag key of the prerequisite that failedpublic static EvaluationReason error(EvaluationReason.ErrorKind errorKind)
kind
is EvaluationReason.Kind.ERROR
.errorKind
- describes the type of errorpublic static EvaluationReason exception(java.lang.Exception exception)
kind
is EvaluationReason.Kind.ERROR
, with an exception instance.
Note that the exception will not be included in the JSON serialization of the reason when it appears in analytics events; it is only provided informationally for use by application code.
exception
- the exception that caused the error