Class ContextKind

  • All Implemented Interfaces:
    JsonSerializable, java.lang.Comparable<ContextKind>

    public final class ContextKind
    extends java.lang.Object
    implements java.lang.Comparable<ContextKind>, JsonSerializable
    A string identifier provided by the application to describe what kind of entity an LDContext represents.

    The type is a simple wrapper for a String. Using a type that is not just String makes it clearer where a context kind is expected or returned in the SDK API, so it cannot be confused with other important strings such as the context key. To convert a literal string to this type, use the factory method of(String).

    The meaning of the context kind is completely up to the application. Validation rules are as follows:

    • It may only contain letters, numbers, and the characters ".", "_", and "-".
    • It cannot equal the literal string "kind".
    • For a single-kind context, it cannot equal "multi".

    If no kind is specified, the default is "user" (the constant DEFAULT).

    For a multi-kind context (see LDContext.createMulti(LDContext...)), the kind of the top-level LDContext is always "multi" (the constant MULTI); there is a specific Kind for each of the contexts contained within it.

    To learn more, read the documentation.

    • Field Detail

      • DEFAULT

        public static final ContextKind DEFAULT
        A constant for the default kind of "user".
      • MULTI

        public static final ContextKind MULTI
        A constant for the kind that all multi-kind contexts have.
    • Method Detail

      • of

        public static ContextKind of​(java.lang.String stringValue)
        Constructor from a string value.

        A value of null or "" will be changed to DEFAULT.

        Parameters:
        stringValue - the string value
        Returns:
        a ContextKind
      • isDefault

        public boolean isDefault()
        True if this is equal to DEFAULT ("user").
        Returns:
        true if this is the default kind
      • toString

        public java.lang.String toString()
        Returns the string value of the context kind. This is never null.
        Overrides:
        toString in class java.lang.Object
      • 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
      • compareTo

        public int compareTo​(ContextKind o)
        Specified by:
        compareTo in interface java.lang.Comparable<ContextKind>