Interface Converter

  • All Known Implementing Classes:
    ConverterImpl

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

      All Methods Instance Methods Abstract Methods 
      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 Detail

      • 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 class
        targetClass - 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 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
        java.lang.IllegalArgumentException - in case the destination field type is null.