Package org.jdbi.v3.core.array
Interface SqlArrayType<T>
-
- Type Parameters:
T- the array element type
- All Known Implementing Classes:
ByteaArrayType,SqlArrayTypeImpl
public interface SqlArrayType<T>Strategy for converting elements of array-like arguments into SQL array elements.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.lang.ObjectconvertArrayElement(T element)Returns an equivalent value in a type supported by the JDBC vendor.default java.lang.Class<?>getArrayElementClass()Returns the element class that is used to create the backing array.java.lang.StringgetTypeName()Returns the vendor-specific SQL type nameStringfor the element typeT.static <T> SqlArrayType<T>of(java.lang.String typeName, java.util.function.Function<T,?> conversion)Create a SqlArrayType from the given type and convert function.
-
-
-
Method Detail
-
getTypeName
java.lang.String getTypeName()
Returns the vendor-specific SQL type nameStringfor the element typeT. This value will be passed toConnection.createArrayOf(String, Object[])to create SQL arrays.- Returns:
- the type name
-
convertArrayElement
java.lang.Object convertArrayElement(T element)
Returns an equivalent value in a type supported by the JDBC vendor. If element typeTis already supported by the JDBC vendor, this method may returnelementwithout modification.- Parameters:
element- the element to convert- Returns:
- the converted element
-
getArrayElementClass
default java.lang.Class<?> getArrayElementClass()
Returns the element class that is used to create the backing array. By default,Objectis used and the backing array is anObject[]array. Can be overridden if a more specific type is needed.- Returns:
- A
Classinstance which is used withArray.newInstance(Class, int).
-
of
static <T> SqlArrayType<T> of(java.lang.String typeName, java.util.function.Function<T,?> conversion)
Create a SqlArrayType from the given type and convert function.- Parameters:
typeName- the vendor sql type to useconversion- convert the array element to the jdbc representation- Returns:
- the created array type
-
-