T - the type of the wrapped valuepublic final class EvaluationDetail<T> extends java.lang.Object implements JsonSerializable
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:
JsonSerialization.
Gson instance with
LDGson.
ObjectMapper instance with
LDJackson.
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.| Modifier and Type | Field and Description |
|---|---|
static int |
NO_VARIATION
If
getVariationIndex() is equal to this constant, it means no variation was chosen
(evaluation failed and returned a default value). |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object other) |
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.
|
EvaluationReason |
getReason()
An object describing the main factor that influenced the flag evaluation value.
|
T |
getValue()
The result of the flag evaluation.
|
int |
getVariationIndex()
The index of the returned value within the flag's list of variations, e.g.
|
int |
hashCode() |
boolean |
isDefaultValue()
Returns true if the flag evaluation returned the default value, rather than one of the flag's
variations.
|
java.lang.String |
toString()
Returns a simple string representation of this instance.
|
public static final int NO_VARIATION
getVariationIndex() is equal to this constant, it means no variation was chosen
(evaluation failed and returned a default value).public static <T> EvaluationDetail<T> fromValue(T value, int variationIndex, EvaluationReason reason)
T - the type of the valuevalue - a value of the desired typevariationIndex - a variation index, or NO_VARIATION (any negative number will be
changed to NO_VARIATION)reason - an EvaluationReason (should not be null)EvaluationDetailpublic static EvaluationDetail<LDValue> error(EvaluationReason.ErrorKind errorKind, LDValue defaultValue)
errorKind - the type of errordefaultValue - the application default valueEvaluationDetailpublic EvaluationReason getReason()
EvaluationReasonpublic int getVariationIndex()
NO_VARIATION.public T getValue()
variation method.public boolean isDefaultValue()
getVariationIndex() will be NO_VARIATION.public boolean equals(java.lang.Object other)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic 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 object's properties, use other methods like getValue().
toString in class java.lang.Object