Package com.launchdarkly.sdk
Class EvaluationDetail<T>
java.lang.Object
com.launchdarkly.sdk.EvaluationDetail<T>
- Type Parameters:
T
- the type of the wrapped value
- All Implemented Interfaces:
JsonSerializable
An object returned by the SDK's "variation detail" methods such as
boolVariationDetail
,
combining the result of a flag evaluation with an explanation of how it was calculated.
EvaluationReason
can be converted to and from 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
.
EvaluationDetail<T>
, or else it will assume that `T` is `LDValue`. If you use either
JsonSerialization
or Jackson, there is no way to specify the runtime type and you
will always get an EvaluationDetail<LDValue>
. That is only for deserialization;
serialization will always use the correct value type.-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
IfgetVariationIndex()
is equal to this constant, it means no variation was chosen (evaluation failed and returned a default value). -
Method Summary
Modifier and TypeMethodDescriptionboolean
static EvaluationDetail<LDValue>
error
(EvaluationReason.ErrorKind errorKind, LDValue defaultValue) Shortcut for creating an instance with an error result.static <T> EvaluationDetail<T>
fromValue
(T value, int variationIndex, EvaluationReason reason) Factory method for an arbitrary value.An object describing the main factor that influenced the flag evaluation value.getValue()
The result of the flag evaluation.int
The index of the returned value within the flag's list of variations, e.g.int
hashCode()
boolean
Returns true if the flag evaluation returned the default value, rather than one of the flag's variations.toString()
Returns a simple string representation of this instance.
-
Field Details
-
NO_VARIATION
public static final int NO_VARIATIONIfgetVariationIndex()
is equal to this constant, it means no variation was chosen (evaluation failed and returned a default value).- See Also:
-
-
Method Details
-
fromValue
public static <T> EvaluationDetail<T> fromValue(T value, int variationIndex, EvaluationReason reason) Factory method for an arbitrary value.- Type Parameters:
T
- the type of the value- Parameters:
value
- a value of the desired typevariationIndex
- a variation index, orNO_VARIATION
(any negative number will be changed toNO_VARIATION
)reason
- anEvaluationReason
(should not be null)- Returns:
- an
EvaluationDetail
-
error
public static EvaluationDetail<LDValue> error(EvaluationReason.ErrorKind errorKind, LDValue defaultValue) Shortcut for creating an instance with an error result.- Parameters:
errorKind
- the type of errordefaultValue
- the application default value- Returns:
- an
EvaluationDetail
-
getReason
An object describing the main factor that influenced the flag evaluation value.- Returns:
- an
EvaluationReason
-
getVariationIndex
public int getVariationIndex()The index of the returned value within the flag's list of variations, e.g. 0 for the first variation, orNO_VARIATION
.- Returns:
- the variation index if applicable
-
getValue
The result of the flag evaluation. This will be either one of the flag's variations or the default value that was passed to thevariation
method.- Returns:
- the flag value
-
isDefaultValue
public boolean isDefaultValue()Returns true if the flag evaluation returned the default value, rather than one of the flag's variations. If so,getVariationIndex()
will beNO_VARIATION
.- Returns:
- true if this is the default value
-
equals
-
hashCode
public int hashCode() -
toString
Returns a simple string representation of this instance.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 object's properties, use other methods like
getValue()
.
-