Interface Converter
- All Known Implementing Classes:
ConverterImpl
public interface Converter
It allows to convert any primitive type into another.
-
Method Summary
Modifier and Type Method Description <T, K> K
convertValue(T valueToConvert, java.lang.Class<K> targetClass)
Converts a given primitive value into the given primitive type.java.util.Optional<java.util.function.Function<java.lang.Object,java.lang.Object>>
getConversionFunction(java.lang.Class<?> sourceClass, java.lang.Class<?> targetClass)
It provides a conversion function for the given primitive type into the other.
-
Method Details
-
getConversionFunction
java.util.Optional<java.util.function.Function<java.lang.Object,java.lang.Object>> getConversionFunction(java.lang.Class<?> sourceClass, java.lang.Class<?> targetClass)It provides a conversion function for the given primitive type into the other.- Parameters:
sourceClass
- source field classtargetClass
- the destination field class- Returns:
- an
Optional
containing the conversion function (if exists)
-
convertValue
<T, K> K convertValue(T valueToConvert, java.lang.Class<K> targetClass)Converts a given primitive value into the given primitive type.- Type Parameters:
T
- the value to convert typeK
- the target object type- Parameters:
valueToConvert
- the value to be convertedtargetClass
- the destination field class- Returns:
- the converted value
- Throws:
TypeConversionException
- in case there is no converter for the given classjava.lang.IllegalArgumentException
- in case the destination field type is null.
-