Class QueryParameterValue (2.26.0)

public abstract class QueryParameterValue implements Serializable

A value for a QueryParameter along with its type.

A static factory method is provided for each of the possible types (e.g. #int64(Long) for StandardSQLTypeName.INT64). Alternatively, an instance can be constructed by calling #of(Object, Class) with the value and a Class object, which will use these mappings:

  • Boolean: StandardSQLTypeName.BOOL
  • String: StandardSQLTypeName.STRING
  • Integer: StandardSQLTypeName.INT64
  • Long: StandardSQLTypeName.INT64
  • Double: StandardSQLTypeName.FLOAT64
  • Float: StandardSQLTypeName.FLOAT64
  • BigDecimal: StandardSQLTypeName.NUMERIC
  • BigNumeric: StandardSQLTypeName.BIGNUMERIC
  • JSON: StandardSQLTypeName.JSON
  • INTERVAL: StandardSQLTypeName.INTERVAL

No other types are supported through that entry point. The other types can be created by calling #of(Object, StandardSQLTypeName) with the value and a particular StandardSQLTypeName enum value.

Struct parameters are currently not supported.

Inheritance

java.lang.Object > QueryParameterValue

Implements

Serializable

Static Methods

<T>array(T[] array, StandardSQLTypeName type)

public static QueryParameterValue <T>array(T[] array, StandardSQLTypeName type)

Creates a QueryParameterValue object with a type of ARRAY the given array element type.

Parameters
NameDescription
arrayT[]
typeStandardSQLTypeName
Returns
TypeDescription
QueryParameterValue

<T>array(T[] array, Class<T> clazz)

public static QueryParameterValue <T>array(T[] array, Class<T> clazz)

Creates a QueryParameterValue object with a type of ARRAY, and an array element type based on the given class.

Parameters
NameDescription
arrayT[]
clazzClass<T>
Returns
TypeDescription
QueryParameterValue

<T>of(T value, StandardSQLTypeName type)

public static QueryParameterValue <T>of(T value, StandardSQLTypeName type)

Creates a QueryParameterValue object with the given value and type.

Parameters
NameDescription
valueT
typeStandardSQLTypeName
Returns
TypeDescription
QueryParameterValue

<T>of(T value, Class<T> type)

public static QueryParameterValue <T>of(T value, Class<T> type)

Creates a QueryParameterValue object with the given value and type. Note: this does not support BigNumeric

Parameters
NameDescription
valueT
typeClass<T>
Returns
TypeDescription
QueryParameterValue

bigNumeric(BigDecimal value)

public static QueryParameterValue bigNumeric(BigDecimal value)

Creates a QueryParameterValue object with a type of BIGNUMERIC.

Parameter
NameDescription
valueBigDecimal
Returns
TypeDescription
QueryParameterValue

bool(Boolean value)

public static QueryParameterValue bool(Boolean value)

Creates a QueryParameterValue object with a type of BOOL.

Parameter
NameDescription
valueBoolean
Returns
TypeDescription
QueryParameterValue

bytes(byte[] value)

public static QueryParameterValue bytes(byte[] value)

Creates a QueryParameterValue object with a type of BYTES.

Parameter
NameDescription
valuebyte[]
Returns
TypeDescription
QueryParameterValue

date(String value)

public static QueryParameterValue date(String value)

Creates a QueryParameterValue object with a type of DATE. Must be in the format "yyyy-MM-dd", e.g. "2014-08-19".

Parameter
NameDescription
valueString
Returns
TypeDescription
QueryParameterValue

dateTime(String value)

public static QueryParameterValue dateTime(String value)

Creates a QueryParameterValue object with a type of DATETIME. Must be in the format "yyyy-MM-dd HH:mm:ss.SSSSSS", e.g. "2014-08-19 12:41:35.220000".

Parameter
NameDescription
valueString
Returns
TypeDescription
QueryParameterValue

float64(Double value)

public static QueryParameterValue float64(Double value)

Creates a QueryParameterValue object with a type of FLOAT64.

Parameter
NameDescription
valueDouble
Returns
TypeDescription
QueryParameterValue

float64(Float value)

public static QueryParameterValue float64(Float value)

Creates a QueryParameterValue object with a type of FLOAT64.

Parameter
NameDescription
valueFloat
Returns
TypeDescription
QueryParameterValue

geography(String value)

public static QueryParameterValue geography(String value)

Creates a QueryParameterValue object with a type of GEOGRAPHY.

Parameter
NameDescription
valueString
Returns
TypeDescription
QueryParameterValue

int64(Integer value)

public static QueryParameterValue int64(Integer value)

Creates a QueryParameterValue object with a type of INT64.

Parameter
NameDescription
valueInteger
Returns
TypeDescription
QueryParameterValue

int64(Long value)

public static QueryParameterValue int64(Long value)

Creates a QueryParameterValue object with a type of INT64.

Parameter
NameDescription
valueLong
Returns
TypeDescription
QueryParameterValue

interval(String value)

public static QueryParameterValue interval(String value)

Creates a QueryParameterValue object with a type of INTERVAL. Must be in the canonical format "[sign]Y-M [sign]D [sign]H:M:S[.F]", e.g. "123-7 -19 0:24:12.000006" or ISO 8601 duration format, e.g. "P123Y7M-19DT0H24M12.000006S"

Parameter
NameDescription
valueString
Returns
TypeDescription
QueryParameterValue

interval(PeriodDuration value)

public static QueryParameterValue interval(PeriodDuration value)

Creates a QueryParameterValue object with a type of INTERVAL.

Parameter
NameDescription
valueorg.threeten.extra.PeriodDuration
Returns
TypeDescription
QueryParameterValue

json(JsonObject value)

public static QueryParameterValue json(JsonObject value)

Creates a QueryParameterValue object with a type of JSON. Currently, this is only supported in INSERT, not in query as a filter

Parameter
NameDescription
valuecom.google.gson.JsonObject
Returns
TypeDescription
QueryParameterValue

json(String value)

public static QueryParameterValue json(String value)

Creates a QueryParameterValue object with a type of JSON. Currently, this is only supported in INSERT, not in query as a filter

Parameter
NameDescription
valueString
Returns
TypeDescription
QueryParameterValue

newBuilder()

public static QueryParameterValue.Builder newBuilder()

Returns a builder for the QueryParameterValue object.

Returns
TypeDescription
QueryParameterValue.Builder

numeric(BigDecimal value)

public static QueryParameterValue numeric(BigDecimal value)

Creates a QueryParameterValue object with a type of NUMERIC.

Parameter
NameDescription
valueBigDecimal
Returns
TypeDescription
QueryParameterValue

string(String value)

public static QueryParameterValue string(String value)

Creates a QueryParameterValue object with a type of STRING.

Parameter
NameDescription
valueString
Returns
TypeDescription
QueryParameterValue

struct(Map<String,QueryParameterValue> struct)

public static QueryParameterValue struct(Map<String,QueryParameterValue> struct)

Creates a map with QueryParameterValue object and a type of STRUCT the given struct element type.

Parameter
NameDescription
structMap<String,QueryParameterValue>
Returns
TypeDescription
QueryParameterValue

time(String value)

public static QueryParameterValue time(String value)

Creates a QueryParameterValue object with a type of TIME. Must be in the format "HH:mm:ss.SSSSSS", e.g. "12:41:35.220000".

Parameter
NameDescription
valueString
Returns
TypeDescription
QueryParameterValue

timestamp(Long value)

public static QueryParameterValue timestamp(Long value)

Creates a QueryParameterValue object with a type of TIMESTAMP.

Parameter
NameDescription
valueLong
Returns
TypeDescription
QueryParameterValue

timestamp(String value)

public static QueryParameterValue timestamp(String value)

Creates a QueryParameterValue object with a type of TIMESTAMP. Must be in the format "yyyy-MM-dd HH:mm:ss.SSSSSSZZ", e.g. "2014-08-19 12:41:35.220000+00:00".

Parameter
NameDescription
valueString
Returns
TypeDescription
QueryParameterValue

Methods

getArrayType()

public abstract StandardSQLTypeName getArrayType()

Returns the data type of the array elements.

Returns
TypeDescription
StandardSQLTypeName

getArrayValues()

public List<QueryParameterValue> getArrayValues()

Returns the array values of this parameter. The returned list, if not null, is immutable.

Returns
TypeDescription
List<QueryParameterValue>

getStructTypes()

public Map<String,QueryParameterValue> getStructTypes()

Returns the data type of the struct elements.

Returns
TypeDescription
Map<String,QueryParameterValue>

getStructValues()

public Map<String,QueryParameterValue> getStructValues()

Returns the struct values of this parameter. The returned map, if not null, is immutable.

Returns
TypeDescription
Map<String,QueryParameterValue>

getType()

public abstract StandardSQLTypeName getType()

Returns the data type of this parameter.

Returns
TypeDescription
StandardSQLTypeName

getValue()

public abstract String getValue()

Returns the value of this parameter.

Returns
TypeDescription
String

toBuilder()

public abstract QueryParameterValue.Builder toBuilder()

Returns a builder for a QueryParameterValue object with given value.

Returns
TypeDescription
QueryParameterValue.Builder