Class ContextKind
- java.lang.Object
-
- com.launchdarkly.sdk.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 anLDContext
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 constantMULTI
); there is a specific Kind for each of the contexts contained within it.To learn more, read the documentation.
-
-
Field Summary
Fields Modifier and Type Field Description static ContextKind
DEFAULT
A constant for the default kind of "user".static ContextKind
MULTI
A constant for the kind that all multi-kind contexts have.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(ContextKind o)
boolean
equals(java.lang.Object other)
int
hashCode()
boolean
isDefault()
True if this is equal toDEFAULT
("user").static ContextKind
of(java.lang.String stringValue)
Constructor from a string value.java.lang.String
toString()
Returns the string value of the context kind.
-
-
-
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 toDEFAULT
("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 classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
compareTo
public int compareTo(ContextKind o)
- Specified by:
compareTo
in interfacejava.lang.Comparable<ContextKind>
-
-