Class EvaluationDetail<T>

  • Type Parameters:
    T - the type of the wrapped value
    All Implemented Interfaces:
    JsonSerializable

    public final class EvaluationDetail<T>
    extends java.lang.Object
    implements 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:

    1. With JsonSerialization.
    2. With Gson, if and only if you configure your Gson instance with LDGson.
    3. With Jackson, if and only if you configure your ObjectMapper instance with LDJackson.
    Note: There is currently a limitation regarding deserialization for generic types. If you use Gson, you must pass a `TypeToken` to specify the runtime type of 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 Detail

      • NO_VARIATION

        public static final int NO_VARIATION
        If getVariationIndex() is equal to this constant, it means no variation was chosen (evaluation failed and returned a default value).
        See Also:
        Constant Field Values
    • Method Detail

      • getVariationIndex

        public int getVariationIndex()
        The index of the returned value within the flag's list of variations, e.g. 0 for the first variation, or NO_VARIATION.
        Returns:
        the variation index if applicable
      • getValue

        public T 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 the variation 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 be NO_VARIATION.
        Returns:
        true if this is the default value
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String 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().

        Overrides:
        toString in class java.lang.Object