Skip to content

MapStruct (1_3_0_Beta2) NullValuePropertyMappingStrategy.IGNORE doesn't work as expected

Notifications You must be signed in to change notification settings

Cepr0/mapstruct-nullvaluepropstrategy-issue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MapStruct (1_3_0_Beta2) NullValuePropertyMappingStrategy with IGNORE value, as described here, doesn't work as expected.

Target

@Data
//@Builder
public class FooBar {

	private int foo;

//	@Builder.Default
	private String bar = "default value";
}

Source

@Value
public class FooBarDto {
	private int foo;
	private String bar;
}

Mapper

@Mapper(nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE)
public interface FoobarMapper {
	FooBar fromDto(FooBarDto fooBarDto);
}

Generated Mapper implementation

public class FoobarMapperImpl implements FoobarMapper {

    @Override
    public FooBar fromDto(FooBarDto fooBarDto) {
        if ( fooBarDto == null ) {
            return null;
        }

        FooBar fooBar = new FooBar();

        fooBar.setFoo( fooBarDto.getFoo() );
        fooBar.setBar( fooBarDto.getBar() );

        return fooBar;
    }
}

Here we can see that mapper doesn't perform the check of fooBarDto.getBar() result for null value;

About

MapStruct (1_3_0_Beta2) NullValuePropertyMappingStrategy.IGNORE doesn't work as expected

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages