Class GenericConverter<SOURCE,​TARGET>

  • All Implemented Interfaces:
    Converter<SOURCE,​TARGET>, org.springframework.core.convert.converter.Converter<SOURCE,​TARGET>

    public class GenericConverter<SOURCE,​TARGET>
    extends java.lang.Object
    implements Converter<SOURCE,​TARGET>
    Converts all properties from source to target that have the same name and have compatible types.
    • Constructor Detail

      • GenericConverter

        public GenericConverter()
    • Method Detail

      • convert

        public TARGET convert​(SOURCE source)
                       throws ConversionException
        Creates a new type of targetClass and converts all properties from source to this new instance that have the same name and have compatible types.
        Specified by:
        convert in interface Converter<SOURCE,​TARGET>
        Specified by:
        convert in interface org.springframework.core.convert.converter.Converter<SOURCE,​TARGET>
        Parameters:
        source - the source object
        Returns:
        the converted object
        Throws:
        ConversionException - if an error occurs
      • convert

        public TARGET convert​(SOURCE source,
                              TARGET prototype)
                       throws ConversionException
        Converts all properties from source to target that have the same name and have compatible types.
        Specified by:
        convert in interface Converter<SOURCE,​TARGET>
        Parameters:
        source - the source object
        prototype - the prototype to fill
        Returns:
        the converted object, identical to the prototype
        Throws:
        ConversionException - if an error occurs
      • setDestClass

        public void setDestClass​(java.lang.Class<TARGET> destClass)
        The class of the target. Used by convert(Object).
        Parameters:
        destClass -