Interface Converter

  • All Known Implementing Classes:
    ConverterImpl

    public interface Converter
    It allows to convert any primitive type into another.
    • Method Detail

      • getConversionFunction

        Optional<Function<Object,​Object>> getConversionFunction​(Class<?> sourceClass,
                                                                      Class<?> targetClass)
        It provides a conversion function for the given primitive type into the other.
        Parameters:
        sourceClass - source field class
        targetClass - the destination field class
        Returns:
        an Optional containing the conversion function (if exists)
      • convertValue

        <T,​K> K convertValue​(T valueToConvert,
                                   Class<K> targetClass)
        Converts a given primitive value into the given primitive type.
        Type Parameters:
        T - the value to convert type
        K - the target object type
        Parameters:
        valueToConvert - the value to be converted
        targetClass - the destination field class
        Returns:
        the converted value
        Throws:
        TypeConversionException - in case there is no converter for the given class
        IllegalArgumentException - in case the destination field type is null.