hi
I encounter a problem which source filed type is Long and dest field type is BigDecimal.I want to convert long to bigdecmial and add a custom convert to mapperfactory , but it's do not work. here is the code
`public class Long2BigDecimalConverter extends BidirectionalConverter<Long, BigDecimal> {
@Override
public BigDecimal convertTo(Long aLong, Type<BigDecimal> type, MappingContext mappingContext) {
return aLong == null ? null : new BigDecimal(aLong);
}
@Override
public Long convertFrom(BigDecimal bigDecimal, Type<Long> type, MappingContext mappingContext) {
return bigDecimal == null ? null : bigDecimal.longValue();
}
}`
`private static MapperFactory mapperFactory = new DefaultMapperFactory.Builder().mapNulls(false).build();
ma.glasnost.orika.MappingException: java.lang.ClassCastException: java.lang.Long cannot be cast to java.math.BigDecimal
at ma.glasnost.orika.impl.ExceptionUtility.newMappingException(ExceptionUtility.java:55) ~[orika-core-1.5.4.jar:?]
at ma.glasnost.orika.impl.MapperFacadeImpl.map(MapperFacadeImpl.java:264) ~[orika-core-1.5.4.jar:?]
at ma.glasnost.orika.impl.MapperFacadeImpl.mapElement(MapperFacadeImpl.java:799) ~[orika-core-1.5.4.jar:?]
at ma.glasnost.orika.impl.MapperFacadeImpl.mapAsCollection(MapperFacadeImpl.java:622) ~[orika-core-1.5.4.jar:?]
at ma.glasnost.orika.impl.MapperFacadeImpl.mapAsList(MapperFacadeImpl.java:420) ~[orika-core-1.5.4.jar:?]
at ma.glasnost.orika.impl.MapperFacadeImpl.mapAsList(MapperFacadeImpl.java:707) ~[orika-core-1.5.4.jar:?]
at com.meituan.trip.performance.calculator.common.util.converter.ModelConverter.convert(ModelConverter.java:54) ~[classes/:?]
hi I encounter a problem which source filed type is Long and dest field type is BigDecimal.I want to convert long to bigdecmial and add a custom convert to mapperfactory , but it's do not work. here is the code
`public class Long2BigDecimalConverter extends BidirectionalConverter<Long, BigDecimal> {
}`
`private static MapperFactory mapperFactory = new DefaultMapperFactory.Builder().mapNulls(false).build();
the exception is
ma.glasnost.orika.MappingException: java.lang.ClassCastException: java.lang.Long cannot be cast to java.math.BigDecimal at ma.glasnost.orika.impl.ExceptionUtility.newMappingException(ExceptionUtility.java:55) ~[orika-core-1.5.4.jar:?] at ma.glasnost.orika.impl.MapperFacadeImpl.map(MapperFacadeImpl.java:264) ~[orika-core-1.5.4.jar:?] at ma.glasnost.orika.impl.MapperFacadeImpl.mapElement(MapperFacadeImpl.java:799) ~[orika-core-1.5.4.jar:?] at ma.glasnost.orika.impl.MapperFacadeImpl.mapAsCollection(MapperFacadeImpl.java:622) ~[orika-core-1.5.4.jar:?] at ma.glasnost.orika.impl.MapperFacadeImpl.mapAsList(MapperFacadeImpl.java:420) ~[orika-core-1.5.4.jar:?] at ma.glasnost.orika.impl.MapperFacadeImpl.mapAsList(MapperFacadeImpl.java:707) ~[orika-core-1.5.4.jar:?] at com.meituan.trip.performance.calculator.common.util.converter.ModelConverter.convert(ModelConverter.java:54) ~[classes/:?]
expect your reply thanks