java.lang.Object
org.jooq.tools.Convert
Deprecated, for removal: This API element is subject to removal in a future version.
Utility methods for type conversions
 
 This class provides less type-safety than the general jOOQ API methods. For
 instance, it accepts arbitrary Converter objects in methods like
 convert(Collection, Converter) and convert(Object, Class),
 trying to retrofit the Object argument to the type provided in
 Converter.fromType() before performing the actual conversion.
- Author:
- Lukas Eder
- 
Field SummaryFieldsModifier and TypeFieldDescriptionDeprecated, for removal: This API element is subject to removal in a future version.All string values that can be transformed into a booleanfalsevalue.Deprecated, for removal: This API element is subject to removal in a future version.All string values that can be transformed into a booleantruevalue.
- 
Constructor SummaryConstructorsConstructorDescriptionConvert()Deprecated, for removal: This API element is subject to removal in a future version.
- 
Method SummaryModifier and TypeMethodDescriptionstatic final Object[]Deprecated, for removal: This API element is subject to removal in a future version.Convert an array of values to a matching data typestatic final Object[]Deprecated, for removal: This API element is subject to removal in a future version.Convert an array of values to a matching data typestatic final <T> TDeprecated, for removal: This API element is subject to removal in a future version.Convert an object to a type.static final <U> UDeprecated, for removal: This API element is subject to removal in a future version.Convert an object to a type.static final <T> List<T>convert(Collection<?> collection, Class<? extends T> type) Deprecated, for removal: This API element is subject to removal in a future version.Convert a collection of objects to a list ofT, usingconvert(Object, Class)static final <U> List<U>convert(Collection<?> collection, Converter<?, ? extends U> converter) Deprecated, for removal: This API element is subject to removal in a future version.Convert a collection of objects to a list ofT, usingconvert(Object, Converter)static final Object[]convertArray(Object[] from, Class<?> toClass) Deprecated, for removal: This API element is subject to removal in a future version.Convert an array into another one by these rulesstatic final <U> U[]convertArray(Object[] from, Converter<?, ? extends U> converter) Deprecated, for removal: This API element is subject to removal in a future version.Convert an array into another one using a converterstatic final <U> U[]convertCollection(Collection from, Class<? extends U[]> to) Deprecated, for removal: This API element is subject to removal in a future version.
- 
Field Details- 
TRUE_VALUESDeprecated, for removal: This API element is subject to removal in a future version.All string values that can be transformed into a booleantruevalue.
- 
FALSE_VALUESDeprecated, for removal: This API element is subject to removal in a future version.All string values that can be transformed into a booleanfalsevalue.
 
- 
- 
Constructor Details- 
Convertpublic Convert()Deprecated, for removal: This API element is subject to removal in a future version.
 
- 
- 
Method Details- 
convertDeprecated, for removal: This API element is subject to removal in a future version.Convert an array of values to a matching data typeThis converts values[i]tofields[i].getType()
- 
convertDeprecated, for removal: This API element is subject to removal in a future version.Convert an array of values to a matching data typeThis converts values[i]totypes[i]
- 
convertArraypublic static final <U> U[] convertArray(Object[] from, Converter<?, ? extends U> converter) throws DataTypeExceptionDeprecated, for removal: This API element is subject to removal in a future version.Convert an array into another one using a converterThis uses convertArray(Object[], Class)to convert the array to an array ofConverter.fromType()first, before converting that array again toConverter.toType()- Parameters:
- from- The array to convert
- converter- The data type converter
- Returns:
- A converted array
- Throws:
- DataTypeException- - When the conversion is not possible
 
- 
convertArrayDeprecated, for removal: This API element is subject to removal in a future version.Convert an array into another one by these rules- If toClassis not an array class, then make it an array class first
- If toClassis an array class, then create an instance from it, and convert all elements in thefromarray one by one, usingconvert(Object, Class)
 - Parameters:
- from- The array to convert
- toClass- The target array type
- Returns:
- A converted array
- Throws:
- DataTypeException- - When the conversion is not possible
 
- If 
- 
convertCollectionDeprecated, for removal: This API element is subject to removal in a future version.
- 
convertpublic static final <U> U convert(Object from, Converter<?, ? extends U> converter) throws DataTypeExceptionDeprecated, for removal: This API element is subject to removal in a future version.Convert an object to a type.- Parameters:
- from- The source object
- converter- The data type converter
- Returns:
- The target type object
- Throws:
- DataTypeException- - When the conversion is not possible
 
- 
convertDeprecated, for removal: This API element is subject to removal in a future version.Convert an object to a type. These are the conversion rules:- nullis always converted to- null, or the primitive default value, or- Optional.empty(), regardless of the target type.
- Identity conversion (converting a value to its own type) is always possible.
- Primitive types can be converted to their wrapper types and vice versa
- All types can be converted to String
- All types can be converted to Object
- All Numbertypes can be converted to otherNumbertypes
- All NumberorStringtypes can be converted toBoolean. Possible (case-insensitive) values fortrue:- 1
- 1.0
- y
- yes
- true
- on
- enabled
 Possible (case-insensitive) values for false:- 0
- 0.0
- n
- no
- false
- off
- disabled
 All other values evaluate to null
- All Datesubtypes (Date,Time,Timestamp), as well as mostTemporalsubtypes (LocalDate,LocalTime,LocalDateTime,OffsetTime,OffsetDateTime, as well asInstant) can be converted into each other.
- All Stringtypes can be converted intoURI,URLandFile
- byte[]and- ByteBuffercan be converted into one another
- byte[]can be converted into- String, using the platform's default charset
- Object[]can be converted into any other array type, if array elements can be converted, too
- All types can be converted into types containing a single argument constructor whose argument is a type that can be converted to according to the above rules.
- All other combinations that are not listed above will result in a
 DataTypeException
 - Parameters:
- from- The object to convert
- toClass- The target type
- Returns:
- The converted object
- Throws:
- DataTypeException- - When the conversion is not possible
 
- 
convertpublic static final <T> List<T> convert(Collection<?> collection, Class<? extends T> type) throws DataTypeException Deprecated, for removal: This API element is subject to removal in a future version.Convert a collection of objects to a list ofT, usingconvert(Object, Class)- Parameters:
- collection- The list of objects
- type- The target type
- Returns:
- The list of converted objects
- Throws:
- DataTypeException- - When the conversion is not possible
- See Also:
 
- 
convertpublic static final <U> List<U> convert(Collection<?> collection, Converter<?, ? extends U> converter) throws DataTypeExceptionDeprecated, for removal: This API element is subject to removal in a future version.Convert a collection of objects to a list ofT, usingconvert(Object, Converter)- Parameters:
- collection- The collection of objects
- converter- The data type converter
- Returns:
- The list of converted objects
- Throws:
- DataTypeException- - When the conversion is not possible
- See Also:
 
 
- 
Converterimplementations, orConverterProviderprovided ones, or implementations attached to fields via generated code, or viaField.convert(Converter), orDataType.asConvertedDataType(Converter).