Class NumberToNumberConverter

java.lang.Object
io.beanmapper.core.converter.impl.NumberToNumberConverter
All Implemented Interfaces:
BeanConverter

public class NumberToNumberConverter extends Object implements BeanConverter
Converts any number to another number type.
Since:
Jun 24, 2015
Author:
Jeroen van Schagen
  • Constructor Details

    • NumberToNumberConverter

      public NumberToNumberConverter()
  • Method Details

    • convert

      public Object convert(BeanMapper beanMapper, Object source, Class<?> targetClass, BeanPropertyMatch beanPropertyMatch)
      Converts the source instance into the desired target type.
      Works by first converting the number into a string and then converting that string back into the target number.
      Specified by:
      convert in interface BeanConverter
      Parameters:
      beanMapper - the instance of BeanMapper to use for further mappings
      source - the source instance
      targetClass - the desired target type
      beanPropertyMatch - information on the field pair (source / target)
      Returns:
      the converted source instance
    • match

      public boolean match(Class<?> sourceClass, Class<?> targetClass)
      Determines if the conversion of our source type to a target type is supported by this converter.
      Specified by:
      match in interface BeanConverter
      Parameters:
      sourceClass - the source class
      targetClass - the target class
      Returns:
      true if the conversion is supported, else false