public static final class DataStoreTypes.DataKind
extends java.lang.Object
The SDK passes instances of this type to the data store to specify whether it is referring to a feature flag, a user segment, etc. The data store implementation should not look for a specific data kind (such as feature flags), but should treat all data kinds generically.
Constructor and Description |
---|
DataKind(java.lang.String name,
java.util.function.Function<DataStoreTypes.ItemDescriptor,java.lang.String> serializer,
java.util.function.Function<java.lang.String,DataStoreTypes.ItemDescriptor> deserializer)
Constructs a DataKind instance.
|
Modifier and Type | Method and Description |
---|---|
DataStoreTypes.ItemDescriptor |
deserialize(java.lang.String s)
Creates an item of this kind from its serialized representation.
|
java.lang.String |
getName()
A case-sensitive alphabetic string that uniquely identifies this data kind.
|
java.lang.String |
serialize(DataStoreTypes.ItemDescriptor item)
Returns a serialized representation of an item of this kind.
|
java.lang.String |
toString() |
public DataKind(java.lang.String name, java.util.function.Function<DataStoreTypes.ItemDescriptor,java.lang.String> serializer, java.util.function.Function<java.lang.String,DataStoreTypes.ItemDescriptor> deserializer)
name
- the value for getName()
serializer
- the function to use for serialize(DataStoreTypes.ItemDescriptor)
deserializer
- the function to use for deserialize(String)
public java.lang.String getName()
This is in effect a namespace for a collection of items of the same kind. Item keys must be unique within that namespace. Persistent data store implementations could use this string as part of a composite key or table name.
public java.lang.String serialize(DataStoreTypes.ItemDescriptor item)
The SDK uses this function to generate the data that is stored by a PersistentDataStore
.
Store implementations normally do not need to call it, except in a special case described in the
documentation for PersistentDataStore
regarding deleted item placeholders.
item
- an DataStoreTypes.ItemDescriptor
describing the object to be serializedjava.lang.ClassCastException
- if the object is of the wrong classpublic DataStoreTypes.ItemDescriptor deserialize(java.lang.String s)
The SDK uses this function to translate data that is returned by a PersistentDataStore
.
Store implementations do not normally need to call it, but there is a special case described in
the documentation for PersistentDataStore
, regarding updates.
The returned DataStoreTypes.ItemDescriptor
has two properties: DataStoreTypes.ItemDescriptor.getItem()
, which
is the deserialized object or a null
value for a deleted item placeholder, and
DataStoreTypes.ItemDescriptor.getVersion()
, which provides the object's version number regardless of
whether it is deleted or not.
s
- the serialized representationDataStoreTypes.ItemDescriptor
describing the deserialized objectpublic java.lang.String toString()
toString
in class java.lang.Object