Class Parameters
- Since:
- 3.0.0
- Author:
- Mark Allen
-
Method Summary
Modifier and TypeMethodDescriptionstatic <E> ArrayParameter
<E> Acquires a SQL ARRAY parameter for a native Java array given an appropriatejava.sql.Array#getBaseTypeName()
.static <E> ArrayParameter
<E> Acquires a SQL ARRAY parameter for aList
given an appropriatejava.sql.Array#getBaseTypeName()
.static JsonParameter
Acquires a JSON parameter for "stringified" JSON, usingJsonParameter.BindingPreference.BINARY
.static JsonParameter
json
(String json, JsonParameter.BindingPreference bindingPreference) Acquires a JSON parameter for "stringified" JSON.static <E> TypedParameter
Acquires a parameter of typeList
, preserving type information so it is accessible at runtime.static <K,
V> TypedParameter Acquires a parameter of typeMap
, preserving key and value type information so they are accessible at runtime.static <E> TypedParameter
Acquires a parameter of typeSet
, preserving type information so it is accessible at runtime.static VectorParameter
vectorOfBigDecimals
(List<BigDecimal> elements) Acquires a vector parameter for aList
ofBigDecimal
.static VectorParameter
vectorOfDoubles
(double[] elements) Acquires a vector parameter for an array ofdouble
.static VectorParameter
vectorOfDoubles
(List<Double> elements) static VectorParameter
vectorOfFloats
(float[] elements) Acquires a vector parameter for an array offloat
.static VectorParameter
vectorOfFloats
(List<Float> elements)
-
Method Details
-
arrayOf
@Nonnull public static <E> ArrayParameter<E> arrayOf(@Nonnull String baseTypeName, @Nullable List<E> list) Acquires a SQL ARRAY parameter for aList
given an appropriatejava.sql.Array#getBaseTypeName()
.You may determine available
baseTypeName
values for your database by examining metadata exposed viaDatabase.readDatabaseMetaData(DatabaseMetaDataReader)
.- Type Parameters:
E
- the element type of the Java list (List<E>
); each element must be bindable tobaseTypeName
by the activePreparedStatementBinder
.- Parameters:
baseTypeName
- the SQL ARRAY element type, e.g."text"
,"uuid"
,"float4"
,"float8"
...list
- the list whose elements will be used to populate the SQL ARRAY- Returns:
- a SQL ARRAY parameter for the given list
-
arrayOf
@Nonnull public static <E> ArrayParameter<E> arrayOf(@Nonnull String baseTypeName, @Nullable E[] array) Acquires a SQL ARRAY parameter for a native Java array given an appropriatejava.sql.Array#getBaseTypeName()
.You may determine available
baseTypeName
values for your database by examining metadata exposed viaDatabase.readDatabaseMetaData(DatabaseMetaDataReader)
.- Type Parameters:
E
- the element type of the Java array (T[]
); each element must be bindable tobaseTypeName
by the activePreparedStatementBinder
.- Parameters:
baseTypeName
- the SQL ARRAY element type, e.g."text"
,"uuid"
,"float4"
,"float8"
...array
- the native Java array whose elements will be used to populate the SQL ARRAY- Returns:
- a SQL ARRAY parameter for the given Java array
-
vectorOfDoubles
Acquires a vector parameter for an array ofdouble
.- Parameters:
elements
- the elements of the vector parameter- Returns:
- the vector parameter
-
vectorOfDoubles
- Parameters:
elements
- the elements of the vector parameter- Returns:
- the vector parameter
-
vectorOfFloats
Acquires a vector parameter for an array offloat
.- Parameters:
elements
- the elements of the vector parameter- Returns:
- the vector parameter
-
vectorOfFloats
- Parameters:
elements
- the elements of the vector parameter- Returns:
- the vector parameter
-
vectorOfBigDecimals
Acquires a vector parameter for aList
ofBigDecimal
.- Parameters:
elements
- the elements of the vector parameter- Returns:
- the vector parameter
-
json
Acquires a JSON parameter for "stringified" JSON, usingJsonParameter.BindingPreference.BINARY
.- Parameters:
json
- the stringified JSON for this parameter- Returns:
- the JSON parameter
-
json
@Nonnull public static JsonParameter json(@Nullable String json, @Nonnull JsonParameter.BindingPreference bindingPreference) Acquires a JSON parameter for "stringified" JSON.- Parameters:
json
- the stringified JSON for this parameterbindingPreference
- how the JSON parameter should be bound to aPreparedStatement
- Returns:
- the JSON parameter
-
listOf
@Nonnull public static <E> TypedParameter listOf(@Nonnull Class<E> elementType, @Nullable List<E> list) Acquires a parameter of typeList
, preserving type information so it is accessible at runtime.This is useful when you want to bind a parameterized collection such as
List<UUID>
orList<String>
and need the generic type argument (e.g.UUID.class
) to be preserved.The resulting
TypedParameter
carries both the runtime value and its generic type so thatCustomParameterBinder.appliesTo(TargetType)
can match against the element type.Note: this kind of parameter requires a corresponding
CustomParameterBinder
to be registered; otherwise, binding will fail-fast.- Type Parameters:
E
- the element type of the list- Parameters:
elementType
- theClass
representing the type of elements contained in the list; used to preserve generic type informationlist
- the list value to wrap; may benull
- Returns:
- a
TypedParameter
representing aList<E>
suitable for use with custom binders
-
setOf
@Nonnull public static <E> TypedParameter setOf(@Nonnull Class<E> elementType, @Nullable Set<E> set) Acquires a parameter of typeSet
, preserving type information so it is accessible at runtime.This is useful when you want to bind a parameterized collection such as
Set<UUID>
orSet<String>
and need the generic type argument (e.g.UUID.class
) to be preserved.The resulting
TypedParameter
carries both the runtime value and its generic type so thatCustomParameterBinder.appliesTo(TargetType)
can match against the element type.Note: this kind of parameter requires a corresponding
CustomParameterBinder
to be registered; otherwise, binding will fail-fast.- Type Parameters:
E
- the element type of the set- Parameters:
elementType
- theClass
representing the type of elements contained in the set; used to preserve generic type informationset
- the set value to wrap; may benull
- Returns:
- a
TypedParameter
representing aSet<E>
suitable for use with custom binders
-
mapOf
@Nonnull public static <K,V> TypedParameter mapOf(@Nonnull Class<K> keyType, @Nonnull Class<V> valueType, @Nullable Map<K, V> map) Acquires a parameter of typeMap
, preserving key and value type information so they are accessible at runtime.This is useful when you want to bind a parameterized collection such as
Map<UUID, Integer>
and need the generic type arguments (e.g.UUID.class
andInteger.class
) to be preserved.The resulting
TypedParameter
carries both the runtime value and its generic type so thatCustomParameterBinder.appliesTo(TargetType)
can match against the element type.Note: this kind of parameter requires a corresponding
CustomParameterBinder
to be registered; otherwise, binding will fail-fast.- Type Parameters:
K
- the key typeV
- the value type- Parameters:
keyType
- the type of the map keysvalueType
- the type of the map valuesmap
- the map value; may benull
- Returns:
- a
TypedParameter
representingMap<K,V>
-