public class FieldValue extends Object implements Serializable
| Modifier and Type | Class and Description |
|---|---|
static class |
FieldValue.Attribute
The field value's attribute, giving information on the field's content type.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
FieldValue.Attribute |
getAttribute()
Returns the attribute of this Field Value.
|
boolean |
getBooleanValue()
Returns this field's value as a
Boolean. |
byte[] |
getBytesValue()
Returns this field's value as a byte array.
|
double |
getDoubleValue()
Returns this field's value as a
Double. |
long |
getLongValue()
Returns this field's value as a
long. |
BigDecimal |
getNumericValue()
Returns this field's value as a
BigDecimal. |
FieldValueList |
getRecordValue()
Returns this field's value as a
FieldValueList instance. |
List<FieldValue> |
getRepeatedValue()
Returns this field's value as a list of
FieldValue. |
String |
getStringValue()
Returns this field's value as a
String. |
long |
getTimestampValue()
Returns this field's value as a
long, representing a timestamp in microseconds since
epoch (UNIX time). |
Object |
getValue()
Returns this field's value as an
Object. |
int |
hashCode() |
boolean |
isNull()
Returns
true if this field's value is null, false otherwise. |
static FieldValue |
of(FieldValue.Attribute attribute,
Object value)
Creates an instance of
FieldValue, useful for testing. |
String |
toString() |
public FieldValue.Attribute getAttribute()
FieldValue.Attribute.PRIMITIVE if the field is a primitive type (LegacySQLTypeName.BYTES, LegacySQLTypeName.BOOLEAN, LegacySQLTypeName.STRING, LegacySQLTypeName.FLOAT, LegacySQLTypeName.INTEGER, LegacySQLTypeName.NUMERIC, LegacySQLTypeName.TIMESTAMP, LegacySQLTypeName.GEOGRAPHY) or is null.
Returns FieldValue.Attribute.REPEATED if the corresponding field has (Field.Mode.REPEATED) mode. Returns FieldValue.Attribute.RECORD if the corresponding field is
a LegacySQLTypeName.RECORD type.
public boolean isNull()
true if this field's value is null, false otherwise.public Object getValue()
public String getStringValue()
String. This method should only be used if the
corresponding field has primitive type (LegacySQLTypeName.BYTES, LegacySQLTypeName.BOOLEAN, LegacySQLTypeName.STRING, LegacySQLTypeName.FLOAT,
LegacySQLTypeName.INTEGER, LegacySQLTypeName.NUMERIC LegacySQLTypeName.TIMESTAMP).ClassCastException - if the field is not a primitive typeNullPointerException - if isNull() returns truepublic byte[] getBytesValue()
LegacySQLTypeName.BYTES.ClassCastException - if the field is not a primitive typeNullPointerException - if isNull() returns trueIllegalStateException - if the field value is not encoded in base64public long getLongValue()
long. This method should only be used if the
corresponding field has LegacySQLTypeName.INTEGER type.ClassCastException - if the field is not a primitive typeNumberFormatException - if the field's value could not be converted to IntegerNullPointerException - if isNull() returns truepublic double getDoubleValue()
Double. This method should only be used if the
corresponding field has LegacySQLTypeName.FLOAT type.ClassCastException - if the field is not a primitive typeNumberFormatException - if the field's value could not be converted to DoubleNullPointerException - if isNull() returns truepublic boolean getBooleanValue()
Boolean. This method should only be used if the
corresponding field has LegacySQLTypeName.BOOLEAN type.ClassCastException - if the field is not a primitive typeIllegalStateException - if the field's value could not be converted to BooleanNullPointerException - if isNull() returns truepublic long getTimestampValue()
long, representing a timestamp in microseconds since
epoch (UNIX time). This method should only be used if the corresponding field has LegacySQLTypeName.TIMESTAMP type.ClassCastException - if the field is not a primitive typeNumberFormatException - if the field's value could not be converted to LongNullPointerException - if isNull() returns truepublic BigDecimal getNumericValue()
BigDecimal. This method should only be used
if the corresponding field has LegacySQLTypeName.NUMERIC type.ClassCastException - if the field is not a primitive typeNumberFormatException - if the field's value could not be converted to BigDecimalNullPointerException - if isNull() returns truepublic List<FieldValue> getRepeatedValue()
FieldValue. This method should only be used if
the corresponding field has Field.Mode.REPEATED mode (i.e. getAttribute() is
FieldValue.Attribute.REPEATED).ClassCastException - if the field has not Field.Mode.REPEATED modeNullPointerException - if isNull() returns truepublic FieldValueList getRecordValue()
FieldValueList instance. This method should only be
used if the corresponding field has LegacySQLTypeName.RECORD type (i.e. getAttribute() is FieldValue.Attribute.RECORD).ClassCastException - if the field is not a LegacySQLTypeName.RECORD typeNullPointerException - if isNull() returns true@BetaApi public static FieldValue of(FieldValue.Attribute attribute, Object value)
FieldValue, useful for testing.
If the attribute is FieldValue.Attribute.PRIMITIVE, the value should be the
string representation of the underlying value, eg "123" for number 123.
If the attribute is FieldValue.Attribute.REPEATED or FieldValue.Attribute.RECORD, the
value should be List of FieldValues or FieldValueList,
respectively.
This method is unstable. See this discussion for more context.
Copyright © 2019 Google LLC. All rights reserved.