public final class DataItem<T>
extends java.lang.Object
null
or empty, it is mandatory field.
String
value cannot be null
, other values are primitive data types. Value is mandatory field.
Type can be STRING, BOOLEAN or DOUBLE, see Type; it is assigned automatically by constructor.Modifier and Type | Class and Description |
---|---|
static class |
DataItem.Type
The data type of the data item.
|
Constructor and Description |
---|
DataItem(java.lang.String key,
boolean value)
Constructor that takes
String key and boolean value. |
DataItem(java.lang.String key,
double value)
Constructor that takes
String key and double value. |
DataItem(java.lang.String key,
java.lang.String value)
Constructor that takes
String key and String value. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object o) |
java.lang.String |
getKey()
Get data item key.
|
DataItem.Type |
getType()
Get data item type.
|
T |
getValue()
Get data item value.
|
int |
hashCode() |
java.lang.String |
toString() |
public DataItem(java.lang.String key, double value)
String
key and double
value. This is to reinforce the value type.key
- data item keyvalue
- data item double valuejava.lang.IllegalArgumentException
- when value is Double.NEGATIVE_INFINITY
, Double.POSITIVE_INFINITY
or Double.NaN
or the key is empty or long string. Maximum length for key
is Message.Utils.MAX_KEY_LENGTH
bytes. The length is measured after
the key is encoded using UTF-8 encoding.java.lang.NullPointerException
- when the key is null
.public DataItem(java.lang.String key, boolean value)
String
key and boolean
value. This is to reinforce the value type.key
- data item keyvalue
- data item boolean valuejava.lang.IllegalArgumentException
- when the key is empty or long string. Maximum length for key is
Message.Utils.MAX_KEY_LENGTH
bytes. The length is measured after the key is encoded
using UTF-8 encoding.java.lang.NullPointerException
- when the key is null
.public DataItem(java.lang.String key, java.lang.String value)
String
key and String
value. This is to reinforce the value typekey
- data item keyvalue
- data item String
valuejava.lang.IllegalArgumentException
- when the key is empty, key or value are long strings. Maximum length for key is
Message.Utils.MAX_KEY_LENGTH
bytes, maximum length for value is
Message.Utils.MAX_STRING_VALUE_LENGTH
bytes. The length is measured after the string is encoded
using UTF-8 encoding.java.lang.NullPointerException
- when the key or value are null
.public final java.lang.String getKey()
DataItem
, never null
.public final T getValue()
DataItem
, never null
.public final DataItem.Type getType()
DataItem
, never null
.public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object