mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#2544: fix missing helper methods for ReverseConversion
This commit is contained in:
parent
196528e578
commit
8ad55b164f
@ -5,12 +5,12 @@
|
||||
*/
|
||||
package org.mapstruct.ap.internal.conversion;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.mapstruct.ap.internal.model.HelperMethod;
|
||||
import org.mapstruct.ap.internal.model.common.Assignment;
|
||||
import org.mapstruct.ap.internal.model.common.ConversionContext;
|
||||
import org.mapstruct.ap.internal.model.common.FieldReference;
|
||||
import org.mapstruct.ap.internal.model.HelperMethod;
|
||||
|
||||
/**
|
||||
* * A {@link ConversionProvider} which creates the inversed conversions for a
|
||||
@ -42,7 +42,7 @@ public class ReverseConversion implements ConversionProvider {
|
||||
|
||||
@Override
|
||||
public List<HelperMethod> getRequiredHelperMethods(ConversionContext conversionContext) {
|
||||
return Collections.emptyList();
|
||||
return conversionProvider.getRequiredHelperMethods( conversionContext );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright MapStruct Authors.
|
||||
*
|
||||
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
package org.mapstruct.ap.test.bugs._2544;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* @author Ben Zegveld
|
||||
*/
|
||||
@Mapper
|
||||
public interface Issue2544Mapper {
|
||||
|
||||
Issue2544Mapper INSTANCE = Mappers.getMapper( Issue2544Mapper.class );
|
||||
|
||||
@Mapping( target = "bigNumber", source = ".", numberFormat = "##0.#####E0" )
|
||||
Target map(String s);
|
||||
|
||||
class Target {
|
||||
|
||||
private BigDecimal bigNumber;
|
||||
|
||||
public BigDecimal getBigNumber() {
|
||||
return bigNumber;
|
||||
}
|
||||
|
||||
public void setBigNumber(BigDecimal bigNumber) {
|
||||
this.bigNumber = bigNumber;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright MapStruct Authors.
|
||||
*
|
||||
* Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
package org.mapstruct.ap.test.bugs._2544;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import org.mapstruct.ap.testutil.IssueKey;
|
||||
import org.mapstruct.ap.testutil.ProcessorTest;
|
||||
import org.mapstruct.ap.testutil.WithClasses;
|
||||
|
||||
/**
|
||||
* @author Ben Zegveld
|
||||
*/
|
||||
@IssueKey( "2544" )
|
||||
@WithClasses( { Issue2544Mapper.class } )
|
||||
public class Issue2544Test {
|
||||
|
||||
@ProcessorTest
|
||||
public void shouldConvert() {
|
||||
Issue2544Mapper.Target target = Issue2544Mapper.INSTANCE.map( "123.45679E6" );
|
||||
|
||||
assertThat( target ).isNotNull();
|
||||
assertThat( target.getBigNumber() ).isEqualTo( new BigDecimal( "1.2345679E+8" ) );
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user